import { getBaseUrl } from '@/services/urlconst';
import { getCompanyID, getPosIDs, getUserDepID, getUserID, requestFunComponFiex } from '@/utils';
import { useRequest } from 'umi';

const baseUrl = getBaseUrl();

/**
 * 编辑主题
 * @param callback 接口调用后的回调
 * @returns
 */
const editThemeService = (callback: (res: any) => void) => {
  const editTheme = useRequest(
    (payload: any) => {
      const params = {
        ...payload,
        modifyCompanyID: getCompanyID(),
        modifyDepartmentID: getUserDepID(),
        modifyPositionID: getPosIDs(),
        modifyerID: getUserID(),
      };
      let reqUrl = `${baseUrl}/themeStyleController/edit`;
      let methodType = 'PUT';
      return requestFunComponFiex(methodType, reqUrl, params);
    },
    {
      manual: true,
      onSuccess: callback,
    },
  );
  return {
    editThemeRun: editTheme?.run,
    editThemeLoading: editTheme?.loading,
  };
};
export { editThemeService };
